<?php

use yii\db\Migration;

class m170831_031215_alter_student_check extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%student_check}}', 'lesson_type', $this->string(20) . ' default \'appointmen\'  comment \'appointmen 预约课次 conversion 转化课次 renew 续费课次\'');
            $this->addColumn('{{%class_lesson}}', 'lesson_type', $this->string(20) . ' default \'appointmen\' comment \'appointmen 预约课次 conversion 转化课次 renew 续费课次\'');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%student_check}}', 'lesson_type');
            $this->dropColumn('{{%class_lesson}}', 'lesson_type');
        }
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m170831_031215_alter_student_check cannot be reverted.\n";

        return false;
    }
    */
}
